package com.example.ontime;

import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;

public class MainActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		Button timeTableDisplayButton = (Button) findViewById(R.id.main_Button);

		final Context context=this; 

		timeTableDisplayButton.setOnClickListener(new View.OnClickListener() {

			//Ce qu'il se passe suite au clic du boutton
			@Override
			public void onClick(View v) {

				//Creation d'un intent: message d'une intention au système!
				Intent i = new Intent(context, FieldSelection.class);
				//appelle de l'activité a lancer avec l'intent correspondant
				MainActivity.this.startActivity(i);

			}
		});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_main, menu);
		return true;
	}
	

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// Handle item selection
		switch (item.getItemId()) {
		case R.id.menu_settings:
			MainActivity.this.startActivity(new Intent(this, SettingActivity.class));
		default:
			return super.onOptionsItemSelected(item);
		}
	}


}
